﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace MetroGA.Core.Hits
{
	internal class EventHit : Hit
	{
		public string Category { get; set; }
		public string Action { get; set; }
		public string Label { get; set; }
		public long? Value { get; set; }
		public string ViewName { get; set; }

		public override IEnumerable<KeyValuePair<string, string>> ToKeyValuePairs()
		{
			var dic = new Dictionary<string, string>
				{
					{"t", "event"},
					{"ec", Category},
					{"ea", Action},
				};

			if (!String.IsNullOrWhiteSpace(Label))
				dic.Add("el", Label);

			if (Value != null)
				dic.Add("ev", Value.Value.ToString());

			if (ViewName != null)
				dic.Add("cd", ViewName);

			return dic.Concat(base.ToKeyValuePairs());
		}
	}
}